package HomeWork;

import com.sun.deploy.util.StringUtils;

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class OneMoTai {

    public static void main(String[] args) {
        HashSet<String> hashSet = new HashSet<String>();
        //创建输入对象
        try (FileReader fileReader = new FileReader("D:\\Idea\\j180git\\11_23\\HomeWorkTxt\\HomeWorkOne.txt");
             FileWriter fileWriter = new FileWriter("D:\\Idea\\j180git\\11_23\\HomeWorkTxt\\HomeWorktwo.txt");
             BufferedReader bufferedReader = new BufferedReader(fileReader);
             BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);) {
            String HomeWorkOne = bufferedReader.readLine();
            String[] strings = HomeWorkOne.split("");
            for (int i = 0; i < strings.length; i++) {
                hashSet.add(strings[i]);
            }
            ArrayList<String> arrayList = new ArrayList<String>(hashSet);
            System.out.println(arrayList+"1");
            int num = hashSet.size();
            Collections.sort(arrayList);
            arrayList.sort(new Comparator<String>() {
                @Override
                public int compare(String o1, String o2) {
                    if (01>02){
                        return -1;
                    }
                    return 1;
                }
            });
            Collections.sort(arrayList,Collections.reverseOrder());
            System.out.println(arrayList+"2");
            StringBuilder string=new StringBuilder();
            for (int i=0;i<arrayList.size();i++){
                string.append(arrayList.get(i));
            }
            System.out.println(string+"3");
            System.out.println(string.substring(0,13)+"4");

            //截取1
            String s1=string.substring(0,13);
            String[] strings1=new String[s1.length()];
            for (int i=0;i<s1.length();i++){
                strings1[i]=s1.charAt(i)+"";
                System.out.print(strings[i]);
            }
            System.out.println("=======");
            ArrayList arrayList1=new ArrayList();
            for (int i=0;i<strings1.length;i++){
                arrayList1.add(strings1[i]);
            }
            System.out.println(arrayList1);
            Collections.sort(arrayList1);
            System.out.println(arrayList1);

            //截取2
            String s2=string.substring(13,15);
            System.out.println(s2);
            String[] strings2=new String[s2.length()];
            for (int i=0;i<s2.length();i++){
                strings2[i]=s2.charAt(i)+"";
            }
            ArrayList arrayList2=new ArrayList();
            for (int i=0;i<strings2.length;i++){
                arrayList2.add(strings2[i]);
            }
            Collections.sort(arrayList2);
            System.out.println(arrayList2+"4");

            //截取三
            String s3=string.substring(15);
            System.out.println(s3);
            String[] strings3=new String[s3.length()];
            for (int i=0;i<s3.length();i++){
                strings3[i]=s3.charAt(i)+"";
            }
            ArrayList arrayList3=new ArrayList();
            for (int i=0;i<strings3.length;i++){
                arrayList3.add(strings3[i]);
            }
            Collections.sort(arrayList3);
            System.out.println(arrayList3);
            arrayList.clear();
            String str1=StringUtils.join(arrayList1, ",");
            String str2=StringUtils.join(arrayList2,",");
            System.out.println(str2);
            String str3=StringUtils.join(arrayList3,",");
            System.out.println(str3);
            String stringzong=str1+","+str2+","+str3;
            System.out.println(str1);
            System.out.println(stringzong);
            String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。， 、？]";
            String regex="";
            stringzong=stringzong.replaceAll(regEx,regex);
            System.out.println(stringzong);
//            ArrayList listzero= (ArrayList) Arrays.asList(stringzong);
            ArrayList<String> arrayList4=new ArrayList();
            String[] strings4=new String[stringzong.length()];
            int number=stringzong.length();
            for (int i = 0; i < number; i++) {
                strings4[i]=stringzong.charAt(i)+"";
            }
            for (int i=0;i<strings4.length;i++){
                System.out.println(strings4[i]);
            }
            for (int i=0;i<strings4.length;i++){
                arrayList4.add(strings4[i]);
            }
            int zero=arrayList4.size();
            for (int i = 0; i < zero; i++) {
                bufferedWriter.write(arrayList4.get(i));
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}